<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('称号列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>称号类型：</label>
                                <select id="typeId" name="typeId" class="form-control">
                                    <option value="">全部</option>
                                    <option th:each="type:${titleTypes}" th:alt-title="${type.describe}" th:value="${type.id}" th:text="${type.typeName}" value="1">
                                        aaa
                                    </option>
                                </select>
                            </li>
                            <li>
                                <label>称号名称：</label>
                                <input type="text" name="title"/>
                            </li>
                            <li>
                                <label>称号描述：</label>
                                <input type="text" name="describe"/>
                            </li>
                            <li>
                                <label>级别：</label>
                                <input type="text" name="level"/>
                            </li>
                            <li>
                                <label>高级称号：</label>
                                <input type="text" name="seniorId"/>
                            </li>
                            <li>
                                <label>等级要求：</label>
                                <input type="text" name="levelMin"/>
                            </li>
                            <li>
                                <label>其他要求：</label>
                                <input type="text" name="otherRequirement"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="fantasy:title:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="fantasy:title:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="fantasy:title:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="fantasy:title:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('fantasy:fantasyTitle:edit')}]];
        var removeFlag = [[${@permission.hasPermi('fantasy:fantasyTitle:remove')}]];
        var propertyRequirementFlag = [[${@permission.hasPermi('fantasy:requirement:list')}]];
        var titleAbilityFlag = [[${@permission.hasPermi('fantasy:fantasyTitleAbility:list')}]];
        var prefix = ctx + "fantasy/fantasyTitle";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "称号",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id', 
                    title: '主键id',
                    visible: false
                },
                {
                    field: 'typeId', 
                    title: '称号类型'
                },
                {
                    field: 'title', 
                    title: '称号名称'
                },
                {
                    field: 'describe', 
                    title: '称号描述'
                },
                {
                    field: 'level', 
                    title: '级别'
                },
                {
                    field: 'seniorId', 
                    title: '高级称号'
                },
                {
                    field: 'levelMin', 
                    title: '等级要求'
                },
                {
                    field: 'otherRequirement', 
                    title: '其他要求'
                },
                {
                    field: 'remark', 
                    title: '备注信息'
                },
                {
                    title: '操作',
                    align: 'center',
                    width:150,
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + propertyRequirementFlag + '" href="#" onclick="propertyRequirement(\'' + row.id + '\')"><i class="fa fa-edit"></i>属性</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + titleAbilityFlag + '" href="#" onclick="titleAbility(\'' + row.id + '\')"><i class="fa fa-edit"></i>能力</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        // 称号管理-属性要求
        function propertyRequirement(id) {
            var url = prefix + '/propertyRequirement/' + id;
            $.modal.openTab("属性要求", url);
        }
        // 称号管理-能力
        function titleAbility(id) {
            var url = prefix + '/titleAbility/' + id;
            $.modal.openTab("能力", url);
        }
    </script>
</body>
</html>